package com.codesuc.aichat.aiAgent.enums;

import com.alibaba.dashscope.aigc.multimodalconversation.AudioParameters;
import com.alibaba.dashscope.audio.ttsv2.enrollment.Voice;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;

/**
 * @Author: ZhangGongMing
 * @CreateTime: 2025-09-28
 * @Description: 角色语音枚举
 * @Version: 1.0
 */
@Getter
public enum RoleVoiceEnum {

    HARRY_POTTER(1971649720071417859L, AudioParameters.Voice.DYLAN.getValue()),

    SOCRATES(1971649720071417860L, AudioParameters.Voice.NOFISH.getValue()),

    EMPRESS_WU_ZETIAN(1971649720071417861L, AudioParameters.Voice.JENNIFER.getValue()),

    LI_BAI(1972104646631649282L, AudioParameters.Voice.LI.getValue()),

    ;

    private Long code;

    private String desc;

     RoleVoiceEnum(Long code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    // 实现根据 roleId 获取角色音色，如果没找到则随机获取一个
    public static String getVoiceByRoleId(Long roleId) {
        for (RoleVoiceEnum roleVoice : RoleVoiceEnum.values()) {
            if (roleVoice.getCode().equals(roleId)) {
                return roleVoice.getDesc();
            }
        }
        // 如果没找到对应的角色音色，随机返回一个
        AudioParameters.Voice[] voices = AudioParameters.Voice.values();
        int randomIndex = (int) (Math.random() * voices.length);
        return voices[randomIndex].getValue();
    }

}
